<?php
defined('IN_IA') or die('Access Denied');
class Meepo_xianchangModuleProcessor extends WeModuleProcessor
{
public function respond() {
		return $res = $this->register();
	}
	
	private function register() { 
		global $_W;
		$qdUrl = $this->createMobileUrl('app_qd',array('rid'=>10));
    	$this->beginContext();
    	return $this->myrespNews($this->buildQdMessage($qdUrl));
	}
	

	private function buildQdMessage($qdUrl) {
	    $title="欢迎参加2017年度表彰大会暨2018年迎新晚会";
	    $text ="欢迎参加南2017年度表彰大会暨2018年迎新晚会";
	    $picurl ='http://wy.linewell.com/sign.jpg';
	   return  array(
            'title' => $title,
            'description' => $text,
            'picurl' => $picurl,
            'url' => $qdUrl
        );
	}
	
	protected function myrespNews(array $news) {
		if (empty($news) || count($news) > 10) {
			return error(-1, 'Invaild value');
		}
		$news = array_change_key_case($news);
		if (!empty($news['title'])) {
			$news = array($news);
		}
		$response = array();
		$response['FromUserName'] = $this->message['to'];
		$response['ToUserName'] = $this->message['from'];
		$response['MsgType'] = 'news';
		$response['ArticleCount'] = count($news);
		$response['Articles'] = array();
		foreach ($news as $row) {
			$response['Articles'][] = array(
					'Title' => $row['title'],
					'Description' => ($response['ArticleCount'] > 1) ? '' : $row['description'],
					'PicUrl' => $row['picurl'],
					'Url' => $this->buildSiteUrl($row['url']),
					'TagName' => 'item'
			);
		}
		return $response;
	}
	
}